import LoginApi from "@/api/account"
import type { AdminUser } from "@/api/account/types"
import { defineStore } from "pinia"

export const useUserStore = defineStore('user',{
	state: ():{
		user:AdminUser
	} =>({
		user:{
			_id: '',
			nickName: '',
			userName: '',
			userType: '',
			avatarUrl: '',
			gender: 0,
			realName: '',
			phone: '',
			status: '',
			access:[]
		}
	}),
	actions: {
		setUserInfo(info){
			this.user=info
		},
		async refreshUserInfo(){
			await LoginApi.getInfo().then(res=>{
				this.user=res.data
			})
		}
	},
	persist: true
})
